package com.mz.ozy.adapter;

import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mz.ozy.R;
import com.mz.ozy.bean.C2cTradeBean;
import com.mz.ozy.utils.StringUtils;
import com.mz.ozy.utils.glideUtils.GlideUtils;

import java.util.List;

public class C2cTradeAdapter extends BaseQuickAdapter<C2cTradeBean.PageBean.PageItemsBean, BaseViewHolder> {

    private final String ktType;

    public C2cTradeAdapter(@Nullable List<C2cTradeBean.PageBean.PageItemsBean> data, String type) {
        super(R.layout.item_trade_center, data);
        this.ktType = type;
    }


    @Override
    protected void convert(BaseViewHolder helper, C2cTradeBean.PageBean.PageItemsBean item) {
        helper.setText(R.id.tvRemark, item.getUsername());
        helper.setText(R.id.tv_price, StringUtils.formattingDecimal(item.getSellPrice(), 2));
        ImageView imageView = helper.getView(R.id.image_icon);
        GlideUtils.loadAvatar(mContext, imageView, item.getUseravatar());

        String tmpUnit = "";
        if ("1".equals(ktType)) {
            tmpUnit = "KT";
        } else {
            tmpUnit = "股权积分";
        }
        helper.setText(R.id.tvTotalNum, mContext.getString(R.string.zgsl, "  " + item.getNum() + tmpUnit));
        helper.setText(R.id.tvBuyNum, mContext.getString(R.string.dmsl, " " + item.getCansell() + tmpUnit));
        helper.addOnClickListener(R.id.tv_submit);
    }


}
